package com.haixee.parkdemo.auth.service.impl;

import com.haixee.parkdemo.auth.dao.JobCustomMapper;
import com.haixee.parkdemo.auth.dao.OrganizeCustomMapper;
import com.haixee.parkdemo.auth.model.Organize;
import com.haixee.parkdemo.auth.service.JobService;
import com.haixee.parkdemo.common.context.WebContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JobServiceImpl implements JobService {

    @Autowired
    private JobCustomMapper jobCustomMapper;

    @Autowired
    private OrganizeCustomMapper organizeCustomMapper;

    @Override
    public List<Organize> getAll() {

        return organizeCustomMapper.selectByType((byte)2, WebContextHolder.getAuth().getTenantId());
    }

    @Override
    public List<Integer> getJobRole(Integer jobId) {
        return jobCustomMapper.selectRoleIdByJobId(jobId);
    }

    @Override
    public void setJobRoles(Integer jobId, List<Integer> roleIdList) {

        jobCustomMapper.deleteByJobId(jobId);
        jobCustomMapper.insertJobRole(jobId, roleIdList);
    }

}
